package com.ly.controller;

import com.ly.constant.ResultCodeConstant;
import com.ly.pojo.domain.CooperationApplicationDO;
import com.ly.pojo.domain.CustomerSupportRequestDO;
import com.ly.pojo.domain.FileDO;
import com.ly.pojo.dto.CooperationApplicationDTO;
import com.ly.pojo.dto.CreateGroup;
import com.ly.pojo.dto.CustomerSupportRequestDTO;
import com.ly.pojo.dto.RestResult;
import com.ly.pojo.dto.UpdateGroup;
import com.ly.pojo.query.CooperationApplicationQuery;
import com.ly.pojo.query.CustomerSupportRequestQuery;
import com.ly.pojo.query.FileQuery;
import com.ly.pojo.query.QueryGroup;
import com.ly.pojo.vo.PageResult;
import com.ly.service.CooperationAndSupportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.lang.Boolean;
import java.lang.Object;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 合作与客户支持管理
 *
 * @author Administrator
 * @date 2025-03-07 10:51:13
 */
@Tag(name = "合作与客户支持管理")
@RequestMapping("cooperation-and-support")
@RestController
public class CooperationAndSupportController {

    @Autowired
    private CooperationAndSupportService cooperationAndSupportService;

    /**
     * 提交加盟申请:验证公司名称和联系人是否已存在
     *
     * @param cooperationApplicationDTO 合作加盟申请入参对象
     * @return
     */
    @RequestMapping(value = "/cooperation-application/add", method = RequestMethod.POST)
    @Operation(summary = "提交加盟申请:验证公司名称和联系人是否已存在")
    @ResponseBody
    public RestResult<Boolean> addCooperationApplication(@RequestBody @Validated(CreateGroup.class) CooperationApplicationDTO cooperationApplicationDTO) {
        Boolean result = cooperationAndSupportService.addCooperationApplication(cooperationApplicationDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 获取加盟申请列表:查询所有加盟申请信息
     *
     * @param cooperationApplicationQuery 合作加盟申请查询入参对象
     * @return
     */
    @RequestMapping(value = "/cooperation-application/list", method = RequestMethod.GET)
    @Operation(summary = "获取加盟申请列表:查询所有加盟申请信息")
    public RestResult<PageResult<CooperationApplicationDO>> getCooperationApplicationList(@Validated(QueryGroup.class) CooperationApplicationQuery cooperationApplicationQuery) {
        PageResult<CooperationApplicationDO> result = cooperationAndSupportService.getCooperationApplicationList(cooperationApplicationQuery);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 更新加盟申请状态:根据ID查询加盟申请信息，如果不存在返回失败信息
     *
     * @param cooperationApplicationDTO 合作加盟申请入参对象
     * @return
     */
    @RequestMapping(value = "/cooperation-application/update", method = RequestMethod.PUT)
    @Operation(summary = "更新加盟申请状态:根据ID查询加盟申请信息，如果不存在返回失败信息")
    @ResponseBody
    public RestResult<Boolean> updateCooperationApplicationStatus(@RequestBody @Validated(UpdateGroup.class) CooperationApplicationDTO cooperationApplicationDTO) {
        Boolean result = cooperationAndSupportService.updateCooperationApplicationStatus(cooperationApplicationDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 提交客户支持请求:保存客户支持请求信息到数据库
     *
     * @param customerSupportRequestDTO 客户支持请求入参对象
     * @return
     */
    @RequestMapping(value = "/customer-support-request/add", method = RequestMethod.POST)
    @Operation(summary = "提交客户支持请求:保存客户支持请求信息到数据库")
    @ResponseBody
    public RestResult<Boolean> addCustomerSupportRequest(@RequestBody @Validated(CreateGroup.class) CustomerSupportRequestDTO customerSupportRequestDTO) {
        Boolean result = cooperationAndSupportService.addCustomerSupportRequest(customerSupportRequestDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 获取客户支持请求列表:查询所有客户支持请求信息
     *
     * @param customerSupportRequestQuery 客户支持请求查询入参对象
     * @return
     */
    @RequestMapping(value = "/customer-support-request/list", method = RequestMethod.GET)
    @Operation(summary = "获取客户支持请求列表:查询所有客户支持请求信息")
    public RestResult<PageResult<CustomerSupportRequestDO>> getCustomerSupportRequestList(@Validated(QueryGroup.class) CustomerSupportRequestQuery customerSupportRequestQuery) {
        PageResult<CustomerSupportRequestDO> result = cooperationAndSupportService.getCustomerSupportRequestList(customerSupportRequestQuery);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 更新客户支持请求状态:根据ID查询客户支持请求信息，如果不存在返回失败信息
     *
     * @param customerSupportRequestDTO 客户支持请求入参对象
     * @return
     */
    @RequestMapping(value = "/customer-support-request/update", method = RequestMethod.PUT)
    @Operation(summary = "更新客户支持请求状态:根据ID查询客户支持请求信息，如果不存在返回失败信息")
    @ResponseBody
    public RestResult<Boolean> updateCustomerSupportRequestStatus(@RequestBody @Validated(UpdateGroup.class) CustomerSupportRequestDTO customerSupportRequestDTO) {
        Boolean result = cooperationAndSupportService.updateCustomerSupportRequestStatus(customerSupportRequestDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 上传文件:处理文件上传并保存文件路径到数据库
     *
     * @param file
     * @return
     */
    @RequestMapping(value = "/file/upload", method = RequestMethod.POST)
    @Operation(summary = "上传文件:处理文件上传并保存文件路径到数据库")
    public RestResult<Boolean> uploadFile(@Validated MultipartFile file) {
        Boolean result = cooperationAndSupportService.uploadFile(file);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * 获取文件列表:查询所有文件信息
     *
     * @param fileQuery 文件查询入参对象
     * @return
     */
    @RequestMapping(value = "/file/list", method = RequestMethod.GET)
    @Operation(summary = "获取文件列表:查询所有文件信息")
    public RestResult<PageResult<FileDO>> getFileList(@Validated(QueryGroup.class) FileQuery fileQuery) {
        PageResult<FileDO> result = cooperationAndSupportService.getFileList(fileQuery);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }
}
